package T1;
import java.util.Scanner;
import java.util.Random;

public class HeroTest {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Random rand = new Random();
        Card[] myCards = new Card[7];
        System.out.println("——————三国抽卡系统——蜀——————");
        int flag = 0;
        while (flag == 0) {
            System.out.println("选项：   1.已有英雄卡牌     2.开始抽取英雄卡牌     3.退出抽取");
            int choice = sc.nextInt();
            if (choice == 1) {
                showCards(myCards);
                System.out.println("-----------------------");
            } else if (choice == 2) {
                int randomNum = rand.nextInt(80);
                Card card = new Card(randomNum);
                System.out.println(card.toString());
                boolean stored = false;
                for (int i = 0; i < myCards.length; i++) {
                    if (myCards[i] == null) {
                        myCards[i] = card;
                        stored = true;
                        break;
                    }
                }
                if (!stored) {
                    System.out.println("卡牌数组已满，无法存储新卡牌。");
                }
                System.out.println("-----------------------");
            } else if (choice == 3) {
                System.out.println("-----------------------");
                System.out.println("已退出");
                flag = 1;
            } else {
                System.out.println("错误，重新输入。");
            }
        }
        sc.close();
    }

    private static void showCards(Card[] cards) {
        for (Card card : cards) {
            if (card != null) {
                System.out.println(card.toString());
            }
        }
    }
}

class Card {
    private String name;
    private int wulizhi;
    private int wenzhi;
    private String shengping;

    @Override
    public String toString() {
        return "Card{" + '\n' +
                "姓名: " + name + '\n' +
                "武值: " + wulizhi + '\n' +
                "文值: " + wenzhi + '\n' +
                "生平: " + shengping + '\n' +
                '}';
    }

    public Card(int i) {
        if (i < 15) {
            name = "刘备(普通)";
            wulizhi = 10;
            wenzhi = 10;
            shengping = "蜀国之主,三兄弟的老二";
        } else if (i < 30) {
            name = "关羽(普通)";
            wulizhi = 12;
            wenzhi = 8;
            shengping = "武圣，三兄弟的老大";
        } else if (i < 45) {
            name = "张飞(普通)";
            wulizhi = 15;
            wenzhi = 5;
            shengping = "三兄弟的老三";
        } else if (i < 55) {
            name = "赵云(稀有)";
            wulizhi = 15;
            wenzhi = 10;
            shengping = "五虎上将之一";
        } else if (i < 65) {
            name = "马超(稀有)";
            wulizhi = 17;
            wenzhi = 8;
            shengping = "五虎上将之一";
        } else if (i < 75) {
            name = "黄忠(稀有)";
            wulizhi = 14;
            wenzhi = 11;
            shengping = "五虎上将之一";
        } else if (i < 80) {
            name = "诸葛亮(传说)";
            wulizhi = 8;
            wenzhi = 30;
            shengping = "卧龙（先生）,武乡侯";
        }
    }
}